package com.hsav.kcxb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hsav.kcxb.R;
import com.zhy.autolayout.utils.AutoUtils;

/**
 * Created by zhao on 2017/4/9.
 */

public class DomainAdapter extends BaseAdapter {

    private final Context mContext;
    private final LayoutInflater mInflater;

    public DomainAdapter(Context context){
        this.mContext = context;
        this.mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return 20;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if(convertView==null){
            convertView = mInflater.inflate(R.layout.item_domain_layout,parent,false);
            viewHolder  = new ViewHolder();
            viewHolder.headImg = (ImageView) convertView.findViewById(R.id.img_head);
            viewHolder.domainTx = (TextView)convertView.findViewById(R.id.tx_domain_name);
            viewHolder.dateTx = (TextView)convertView.findViewById(R.id.tx_date);
            convertView.setTag(viewHolder);
            AutoUtils.autoSize(convertView);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.headImg.setImageResource(R.drawable.head);
        viewHolder.domainTx.setText("地址是"+position);
        viewHolder.dateTx.setText("日期是"+position);
        return convertView;
    }

    class ViewHolder{
        ImageView headImg;
        TextView domainTx;
        TextView dateTx;
    }
}
